package com.czh.springboot04.service.serviceimpl;


import com.czh.springboot04.entity.Specialty;
import com.czh.springboot04.mapper.SpecialtyMapper;
import com.czh.springboot04.service.SpecialtyService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SpecialtyServiceImpl implements SpecialtyService {
    @Autowired
    private SpecialtyMapper specialtyMapper;

    @Override
    public int insert(Specialty specialty) {
        int i = specialtyMapper.insert(specialty);
        return i;
    }

    @Override
    public int update(Specialty specialty) {
        int i = specialtyMapper.update(specialty);
        return i;
    }

    @Override
    public int delete(int id) {
        int i = specialtyMapper.delete(id);
        return i;
    }

    @Override
    public PageInfo<Specialty> selectByPage(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Specialty> list = specialtyMapper.selectByPage();
        PageInfo<Specialty> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public Specialty selectById(int id) {
      return specialtyMapper.selectById(id);
    }
}
